package com.kadron.news;

import java.io.Serializable;

import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

import com.kadron.dao.KNewsDAO;
import com.kadron.entity.News;
import com.kadron.manager.KMessageManager;

@AutoCreate
@Name("kViewNewsManager")
@Scope(ScopeType.PAGE)
public class KViewNewsManager extends KMessageManager implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4184026689307942094L;

	private News news; 
	
	@In
	private KNewsDAO newsDAO; 
	
	@Create
	public void init() {
		Long newsId = (Long) Component.getInstance("newsId");
		if (newsId == null || newsId <= 0) {
			setError(true);
			return;
		}
		news = (News) newsDAO.find(newsId, News.class);
	}
	
	public News getNews() {
		return news;
	}

}